
#include <objectmanager.h>


SceneObject::SceneObject ()
{
}

void SceneObject::SetCategory(const Category &category)
{
  _category = category;
}

Category& SceneObject::GetCategory()
{
  return _category;
}

const Category& SceneObject::GetCategory() const
{
  return _category;
}

void SceneObject::SetName(const QString &name)
{
  _name = name;
}

const QString& SceneObject::GetName() const
{
  return _name;
}

void SceneObject::SetFilename(const QString &filename)
{
  _filename = filename;
}

const QString& SceneObject::GetFilename() const
{
  return _filename;
}

ObjectManager::ObjectManager()
{
}

void ObjectManager::AddObject(SceneObject *object)
{
  _objects.push_back(object);

  emit ObjectAdded (object);
}


void ObjectManager::RemoveObject(SceneObject *object)
{
  if (_objects.contains(object))
    {
      _objects.removeAll(object);
      emit ObjectRemoved (object);
      delete object;
    }
}

void ObjectManager::MoveObject(SceneObject *object)
{
  emit ObjectMoved(object);
}

void ObjectManager::ChangeObject(SceneObject *object)
{
  emit ObjectChanged(object);
}

void ObjectManager::RenameCategory(Category catOld, Category catNew)
{
  foreach (SceneObject* object , _objects)
    {
      if (object->GetCategory().FreeRename(catOld, catNew))
        {
          emit ObjectMoved(object);
        }
    }
}

void ObjectManager::RemoveCategory(Category category)
{
  foreach (SceneObject* object , _objects)
    {
      if (object->GetCategory().Remove(category))
        {
          emit ObjectMoved(object);
        }
    }
}
unsigned ObjectManager::GetNumberOfObjects() const
{
  return _objects.size();
}

SceneObject* ObjectManager::GetObject(unsigned idx)
{
  return _objects.at(idx);
}
